/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.animation.time;

import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.EndGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.main.MainGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object.interfaces.Generatable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.animationTime.KeyFrame;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Transformation;

/**
 *
 * @author Admin
 */
public class KeyFrameGenerator implements Generator,Generatable{

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof KeyFrame)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        this.generateStart(sb);
        this.generateUniqueAttributes(sb, o,recursionLevel);
        this.generateValues(sb, (KeyFrame)o,recursionLevel,original);
        this.generateEnd(sb);
    }
    @Override
    public void generateStart(StringBuilder sb){
        sb.append("KeyFrame{\n");
    }
    @Override
    public void generateEnd(StringBuilder sb){
        EndGenerator.generateEnd(sb);
    }
    @Override
    public void generateUniqueAttributes(StringBuilder sb, Object o,int recursionLevel){
        KeyFrame k = (KeyFrame)o;
        sb.append("time:"+k.getTime()+"s;\n");
    }
    public void generateValues(StringBuilder sb,KeyFrame k,int recursionLevel,Object original){
        sb.append("values:[\n");
        for(Transformation t : k.getTransformations()){
            MainGenerator.generateNext(t,recursionLevel,original);
        }
        sb.append("]\n");
    }

}
